home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3p / uscas.z / uscas
Encoding:
Text File  |  1998-10-20  |  2.7 KB  |  67 lines

  1.  
  2.  
  3.  
  4. UUUUSSSSCCCCAAAASSSS((((3333PPPP))))                                                            UUUUSSSSCCCCAAAASSSS((((3333PPPP))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      uscas, uscas32 - compare and swap operator
  10.  
  11. CCCC SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<uuuulllloooocccckkkkssss....hhhh>>>>
  13.  
  14.      iiiinnnntttt  uuuussssccccaaaassss((((vvvvooooiiiidddd ****ddddeeeessssttttpppp,,,, ppppttttrrrrddddiiiiffffffff____tttt oooolllldddd,,,, ppppttttrrrrddddiiiiffffffff____tttt nnnneeeewwww,,,, uuuussssppppttttrrrr____tttt ****uuuu))));;;;
  15.      iiiinnnntttt  uuuussssccccaaaassss33332222((((vvvvooooiiiidddd ****ddddeeeessssttttpppp,,,, iiiinnnntttt33332222____tttt oooolllldddd,,,, iiiinnnntttt33332222____tttt nnnneeeewwww,,,, uuuussssppppttttrrrr____tttt ****uuuu))));;;;
  16.  
  17. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  18.      _u_s_c_a_s emulates a hardware compare and swap instruction.  It works on both
  19.      single and multi-processor machines.  The exact algorithm used depends on
  20.      the chip and system type.  _u_s_c_a_s checks that the contents of _d_e_s_t_p are
  21.      equal to _o_l_d and if they are, atomically changes the contents of _d_e_s_t_p to
  22.      _n_e_w.  If the contents are not the same, a zero is returned and the
  23.      operation may be repeated.  Note that even with one process performing
  24.      this algorithm, the compare and swap operation may fail, so the caller
  25.      must always be prepared to loop.  _u points to a previously set up arena
  26.      (using _u_s_i_n_i_t(3P)).
  27.  
  28.      _u_s_c_a_s does a compare and swap on 32-bits for 32-bit processes and 64-bits
  29.      for 64-bit processes.
  30.      _u_s_c_a_s_3_2 does a compare and swap on 32-bits regardless of the type of the
  31.      process.
  32.  
  33. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  34.      acquire_lock(3), usinit(3P), ussetlock(3P), uspsema(3P).
  35.  
  36. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  37.      A value of 1 returned when a successful compare and swap has been
  38.      performed.  Otherwise 0 is returned.  There are no errors.
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.